<?php 
require "DataLoad.php";
CheckAdmin2();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?php echo $GuildName;?> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<?php echo $StylePath;?>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<?php echo $StylePath;?>/styleplus.js"></script>
<style type="text/css" media="all">

</style>
</head>

<body>
<div class="header">
<?php require "menu.php"; ?>
</div>
<div class="main">
			<?php 
$manager = new SystemManager();


switch (${"action"}) {
	case "addclass":
SQLClass("add",0);
		break;
	case "editclass":
SQLClass("edit",$_POST["id"]);
		break;
	case "delclass":
SQLClass("del",${"id"});
		break;
} 

switch (${"Action"}) {
	case "edit":
guild_edit_sql();
		break;
	default:

echo $manager->viewGuildInfoForm();
RaidClassList();
		break;
} 

?>
	</div>
<?php require "footer.php"; ?>
</body>
</html>
<?php 







function RaidClassList() {
	extract($GLOBALS);

	$HtmlList=$HtmlList."<table class='outframe interlace'>";
	$HtmlList=$HtmlList."<tr><th colspan='4'>公会DKP分类设置 [<a href='admin_GuildInfo.php'>添加新分类</a>]</th></tr>";
	$HtmlList=$HtmlList."<tr class='coltitle'><td>ID</td><td>分类名(字符范围:A-Z,a-z,0-9)</td><td>描述</td><td>建议不要删除已有分类</td></tr>";
	$sql="select * from raid_class";
	$result = mysql_query($sql);
	if (!($result->eof || $result->bof)) {

		for ($i=1; $i<=$result->recordcount; $i=$i+1) {
			if (${"action"}=="editform" && intval(${"id"})==$result["id"]) {

				$HtmlList=$HtmlList."<tr><form method='post' action='?action=editclass'><td><input type='hidden' name='id' value='".$result["id"]."' />".$result["id"]."</td><td><input type='text' name='class_name' value='".$result["class_name"]."' /></td><td><input type='text' name='class_note' value='".$result["class_note"]."' /></td><td><input type='submit' value='完 成' /></td></form></tr>";
			}
				else
			{

				$HtmlList=$HtmlList."<tr><td>".$result["id"]."</td><td>".$result["class_name"]."</td><td>".$result["class_note"]."</td><td><a href='?action=editform&amp;id=".$result["id"]."'>编辑</a> <a href='?action=delclass&amp;id=".$result["id"]."'>删除</a></td></tr>";
			} 

			$result->movenext;

		}

	}
		else
	{

		$HtmlList=$HtmlList."<tr><td colspan='4'>没有设置分类,系统正常运行至少需要一个DKP分类.</td></tr>";
	} 

	$result->close;
	if (${"action"}=="") {
		$HtmlList=$HtmlList."<tr><form method='post' action='?action=addclass'><td></td><td><input type='text' name='class_name' value='' /></td><td><input type='text' name='class_note' value='' /></td><td><input type='submit' value='添 加' /></td></form></tr>";
	} 
	$HtmlList=$HtmlList."</table>";

	print $HtmlList;
	return $function_ret;
} 

function SQLClass($action,$id) {

	if (!is_numeric($id)) {
		return $function_ret;

	} 
	if ($action=="del") {

		$Conn->execute("Delete * from Raid_class where id=".$id);
		return $function_ret;

	} 

//添加新的分类
//验证提交数据有效性
	if (${"class_name"}=="") {
		$errorinfo=$errorinfo."<li>分类名请不要留空.</li>";
	} 
//验证///

	if ($errorinfo!="") {

//抛出错误提示
		print "<p>表单信息有误,提示如下:</p><ul>".$errorinfo."</ul>";
		print "请<a href='".$Url."'>返回</a>重新修改.";
	}
		else
	{

//写入数据库
		if ($action=="add") {

			print "Done.3";
			$sql="select top 1 * from raid_class";
			$result = mysql_query($sql);
			$result->addnew;
			$result["class_name"]=${"class_name"};
			$result["class_note"]=${"class_note"};
			$result->update;
			$result->close;
		}
			else
		if ($action=="edit") {

			print "Done.";
			$sql="select top 1 * from raid_class where id=".$id;
			$result = mysql_query($sql);
			if (!($result->bof || $result->eof)) {

				$result["class_name"]=${"class_name"};
				$result["class_note"]=${"class_note"};
				$result->update;
				$result->close;
			} 

		} 

	} 

	return $function_ret;
} 

?>
